/**
 * @author Sudarsan This Class provides a Test for the Object Employee
 */
public class EmployeeTest {

	/**
	 * @param args
	 *            Starting point of the App
	 */
	public static void main(String[] args) {

		EmployeeService employeeService = new EmployeeService();
		Employee employee = null;
		String option = null;

		do {
			KeyBoard.write("M E N U\n");
			KeyBoard.write("========\n\n");
			KeyBoard.write("[1].CREATE\t\t[2].LIST\n\n[3].FIND\t\t[4].EXIT\n\n");

			int choice = KeyBoard.readInt("Enter Your Choice ========>>> : ");

			switch (choice) {

			case 1:
				employee = new Employee();
				employee.setEmployeeId(KeyBoard.readInt("Enter Id : "));
				employee.setEmployeeName(KeyBoard.readString("Enter Name : "));
				employee.setSalary(KeyBoard.readDouble("Enter Salary :  "));
				employeeService.create(employee);
				KeyBoard.write("===>Record Created<===");
				break;

			case 2:

				Employee[] employees = employeeService.getAll();
				for (int i = 0; i < EmployeeService.USER_COUNT; i++) {

					employee = employees[i];

					KeyBoard.write(employee.getEmployeeId() + "\t"
							+ employee.getEmployeeName() + "\t"
							+ employee.getSalary());
				}
				break;

			case 3:
				employee = employeeService.findById(KeyBoard
						.readInt("Enter Id to Search : "));

				if (employee != null) {
					KeyBoard.write("===>Record Found<===");
					KeyBoard.write(employee.getEmployeeId() + "\t"
							+ employee.getEmployeeName() + "\t"
							+ employee.getSalary());
				} else {
					KeyBoard.write("===>Record Not Found<===");
				}

				break;

			case 4:
				System.exit(0);
				break;

			default:
				KeyBoard.write("Enter Valid Choice between (1..4)");
				break;

			}

			option = KeyBoard.readString("Do You want to Continue (Y/N) ? : ");
		} while (option.equalsIgnoreCase("Y"));

	}
}
